#include<bits/stdc++.h>
using namespace std;
int main() {
  vector<int> p;
  int i;
  while(cin>>i) {
    p.push_back(i);
  }
  sort(p.begin(),p.end());
  do{
    for(auto el:p) {
      cout << el << " ";
    }
    cout << endl;
  }while(next_permutation(p.begin(),p.end()));
  return 0;
}
